distance formula and endpoints of a right triangle